import time
from selenium import webdriver
from selenium.webdriver.common.by import By
driver = webdriver.Chrome()
driver.maximize_window()
driver.implicitly_wait(10)
driver.get("http://192.168.0.108/")
driver.find_element(By.XPATH, '//*[@id="navitems"]/li[2]/a').click()
time.sleep(3)
driver.find_element(By.XPATH, '//*[@id="navitems"]/li[3]/a').click()
time.sleep(3)
driver.find_element(By.XPATH, '//*[@id="navitems"]/li[4]/a').click()
time.sleep(3)
# 获取当前窗口句柄信息
print(driver.current_window_handle)
# 获取所有窗口句柄
windows = driver.window_handles
print(windows)
# 切换窗口句柄
time.sleep(3)
driver.switch_to.window(windows[0])
print(driver.current_window_handle)
time.sleep(10)
# 在注册A页中输入用户名和密码
driver.find_element(By.XPATH, '//*[@id="cata-nav"]/div[1]/div[1]/h3/div/a').click()
# driver.find_element(By.ID, 'username').send_keys("13125056588")
# driver.find_element(By.ID, 'password').send_keys("Dd112211")
time.sleep(5)
driver.quit()